<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 85167
  Date: 2017/12/10
  Time: 11:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <c:import url="/WEB-INF/page/header.jsp"/>
</head>
<body>
<div class="col-md-12">
    <form id="roleForm" action="${pageContext.request.contextPath}/admin/role/save" method="post">
        <input type="hidden" name="id" value="${id}">
        <table class="table">
            <thead>
            <tr>
                <th>角色</th>
                <th>选择</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${roles}" var="vo">
                <tr>
                    <td>${vo.name}</td>
                    <td><input name="roles" class="checkbox i-checks" type="checkbox" value="${vo.id}"></td>
                </tr>
            </c:forEach>

            </tbody>
        </table>
        <div class="form-group">
            <div class="col-sm-12 col-sm-offset-3">
                <button class="btn btn-primary" type="button" onclick="save()">保存</button>
                <button class="btn btn-white" type="button" onclick="cancel()">取消</button>
            </div>
        </div>
    </form>
</div>
<c:import url="/WEB-INF/page/footer.jsp"/>
<script type="text/javascript">
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });


    function save() {
        ;
        $.ajax({
            url: base + "/admin/admin_user/save_auth",
            data: $("#roleForm").serialize(),
            type: "post",
            dataType: "json",
            success: function (data) {
                swal("操作成功！", "保存成功", "success");
            },
            error: function (data) {
                swal("系统异常！", data.msg, "error");
            }
        });
    }

    function cancel() {
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
    }
</script>
</body>
</html>
